//
//  LCVideoTbCell.m
//  TheLCNews
//
//  Created by apple on 15/11/26.
//  Copyright © 2015年 LC. All rights reserved.
//

#import "LCVideoTbCell.h"
#import "LCVideoModel.h"



@implementation LCVideoTbCell



- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.bigView = [[UIView alloc] init];
        [self.contentView addSubview:_bigView];
        
        self.picView = [[UIImageView alloc] init];
        [_bigView addSubview:_picView];
        
        self.centerImage = [[UIImageView alloc] init];
        [_picView addSubview:_centerImage];
        
        self.titleLabel = [[UILabel alloc] init];
        [_bigView  addSubview:_titleLabel];
        
        self.smallTitle = [[UILabel alloc] init];
        [_bigView  addSubview:_smallTitle];
        
        self.lineView = [[UIView alloc] init];
        [_bigView  addSubview:_lineView];
        
        self.timeImage = [[UIImageView alloc] init];
        [_bigView  addSubview:_timeImage];
        
        self.timeLabel = [[UILabel alloc] init];
        [_bigView  addSubview:_timeLabel];
        
        self.playImageView = [[UIImageView alloc] init];
        [_bigView  addSubview:_playImageView];
        
        self.playLabel = [[UILabel alloc] init];
        [_bigView  addSubview:_playLabel];
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.bigView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).with.offset(15);
        make.right.equalTo(self.contentView).with.offset(-15);
        make.height.mas_equalTo(CWIDTH / 1.2);
        make.top.equalTo(self.contentView.mas_top).with.offset(10);
        
        self.bigView.backgroundColor = [UIColor whiteColor];
        _bigView.layer.masksToBounds = NO;
        _bigView.layer.shadowColor = [UIColor blackColor].CGColor;
        _bigView.layer.shadowOffset = CGSizeMake(0.0f, 5.0f);
        _bigView.layer.shadowOpacity = 0.5f;
        
    }];
    
    [self.picView mas_makeConstraints:^(MASConstraintMaker * make) {
        make.left.equalTo(self.bigView).with.offset(2);
        make.right.equalTo(self.bigView).with.offset(-2);
        make.top.equalTo(self.contentView.mas_top).with.offset(10);
        make.height.mas_equalTo(CWIDTH  / 2);
        self.picView.backgroundColor = [UIColor purpleColor];
    }];
    
    
    [self.centerImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.picView);
        make.size.mas_equalTo(CGSizeMake(50, 50));
        self.centerImage.layer.cornerRadius = 25;
        //        self.centerImage.backgroundColor = [UIColor orangeColor];
        self.centerImage.image = [UIImage imageNamed:@"movie_list_palyFocusIcon_night"];
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.picView).with.offset(10);
        make.right.equalTo(self.picView).with.offset(-10);
        make.top.equalTo(self.picView.mas_bottom).with.offset(10);
        make.height.mas_equalTo(20);
        self.titleLabel.font = [UIFont boldSystemFontOfSize:18];
        //        self.titleLabel.backgroundColor = [UIColor blueColor];
    }];
    
    [self.smallTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.picView).with.offset(10);
        make.right.equalTo(self.picView).with.offset(-10);
        make.top.equalTo(self.titleLabel.mas_bottom).with.offset(10);
        make.height.mas_equalTo(15);
        //        self.smallTitle.backgroundColor = [UIColor purpleColor];
        self.smallTitle.textColor = [UIColor grayColor];
        self.smallTitle.font = [UIFont systemFontOfSize:15];
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.picView).with.offset(10);
        make.right.equalTo(self.picView).with.offset(-10);
        make.top.equalTo(self.smallTitle.mas_bottom).with.offset(5);
        make.height.mas_equalTo(1);
        self.lineView.backgroundColor = [UIColor grayColor];
    }];
    
    [self.timeImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.picView).with.offset(10);
        make.width.mas_equalTo(20);
        make.top.equalTo(self.lineView.mas_bottom).with.offset(10);
        make.height.mas_equalTo(20);
        self.timeImage.layer.cornerRadius = 10;
        //        self.timeImage.backgroundColor = [UIColor yellowColor];
        self.timeImage.image = [UIImage imageNamed:@"movie_list_durationIcon@3x"];
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.timeImage.mas_right).with.offset(10);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(20);
        self.timeLabel.font = [UIFont systemFontOfSize:17];
        self.timeLabel.textColor = [UIColor grayColor];
        make.top.equalTo(self.lineView.mas_bottom).with.offset(10);
        //        self.timeLabel.backgroundColor = [UIColor purpleColor];
    }];
    
    
    [self.playImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.timeLabel.mas_right).with.offset(50);
        make.width.mas_equalTo(20);
        make.top.equalTo(self.lineView.mas_bottom).with.offset(10);
        make.height.mas_equalTo(20);
        self.playImageView.layer.cornerRadius = 10;
        //        self.playImageView.backgroundColor = [UIColor yellowColor];
        self.playImageView.image = [UIImage imageNamed:@"liveRoom_smallPlay@3x"];
    }];
    
    [self.playLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.playImageView.mas_right).with.offset(10);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(20);
        make.top.equalTo(self.lineView.mas_bottom).with.offset(10);
        self.playLabel.font = [UIFont systemFontOfSize:17];
        self.playLabel.textColor = [UIColor grayColor];
        //        self.playLabel.backgroundColor = [UIColor purpleColor];
    }];
    
    
    
}


- (void)setModel:(LCVideoModel *)model{
    
    [self.picView sd_setImageWithURL:[NSURL URLWithString:model.cover] placeholderImage:[UIImage imageNamed:@"zhanwei"]];
    //    NSURL *url = [NSURL URLWithString:model.mp4_url];
    //    NSLog(@"789       %@",url);
    //    self.movie.contentURL = url;
    self.titleLabel.text = model.title;
    self.smallTitle.text = model.description;
    NSString *str = model.ptime;
    self.timeLabel.text = [str substringWithRange:NSMakeRange(11, 5)];
    self.playLabel.text = [NSString stringWithFormat:@"%d%@",model.playCount / 10000,@"万"];
    //    self.movie.
    NSLog(@"%@",self.timeLabel.text);
    
    
}



/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
